X3D 3D Everywhere

VRML -> X3D

Introducing
X3D



X3D XML Syntax Overview (3)


X3D XML Examples

Some more examples of the XML encoding and how the .x3d file is composed.


X3D Appearance and Material Schema

  <xsd:element name="Appearance">
    <xsd:all>
      <xsd:element ref="ImageTexture"/>
      <xsd:element ref="Material"/>
      <xsd:element ref="MovieTexture"/>
      <xsd:element ref="PixelTexture"/>
      <xsd:element ref="TextureTransform"/>
    </xsd:all>
  </xsd:element>


  <xsd:element name="Material">
    <xsd:attribute name="ambientIntensity" type="Float" default="0.2" />
    <xsd:attribute name="diffuseColor" type="Color" default="0.8 0.8 0.8" />
    <xsd:attribute name="emissiveColor" type="Color" default="0 0 0" />
    <xsd:attribute name="shininess" type="Float" default="0.2" />
    <xsd:attribute name="specularColor" type="Color" default="0 0 0" />
    <xsd:attribute name="transparency" type="Float" default="0" />
  </xsd:element>

X3D XML Appearance, Material.
If both a Material (in Appearance)and a Color node (as a GeometricPropertyNode) are specified for a geometric Shape, the ColorNode shall replace the diffuseColor component of the Material.

Results

    <Shape> 
      <Appearance> 
        <Material/> 
      </Appearance> 
      <Box/> 
    </Shape> 


    <Material ambientIntensity='Float' diffuseColor='Color'
          emissiveColor='Color' shininess='Float'
          specularColor='Color' transparency='Float' />

    <Material ambientIntensity='0.2' diffuseColor='0.8 0.8 0.8'
          emissiveColor='0 0 0' shininess='0.2'
          specularColor='0 0 0' transparency='0' />


    <Transform translation='6.1 0.6 -3.0'> 
       <Shape> 
         <Appearance> 
           <Material/> 
         </Appearance> 
         <Box/> 
       </Shape> 
    </Transform> 

Shape, Default Material, and Transform.

Encoding Choices

Current: SF/MFfield is name='value' pair:

  <Transform center='0.5 0 -0.7' 
              translation='6.1 0.6 -3.0'
              rotation='0.6 0 1 0.157' 
              scale='2 3 5' 
              scaleOrientation='0.5 0 1 -1'
              rotation='0 0 1 0' >
      ... ChildNodes ...
  </Transform> 

Simplified:

  <Transform translation='6.1 0.6 -3.0' 
              ... moreattrs ... >
      ... ChildNodes ...
  </Transform> 

Empty elements and simple attributes:

  <Transform> 
     <translation x='6.1' y='0.6' z='-3.0' /> 
     <... moreattrs ... />
        ... ChildNodes ...
  </Transform> 

All simple attributes:

  <Transform translationX='6.1' 
              translationY='0.6' 
              translationZ='-3.0' 
              ... moreattrs ... > 
      ... ChildNodes ...
  </Transform> 

All elements with cdata content:

  <Transform> 
     <translation> 6.1 0.6 -3.0 </translation>
     <... moreattrs ... > ... </... moreattrs ...>
        ... ChildNodes ...
  </Transform> 

Elements with elements with content:

  <Transform> 
     <translation> 
        <x> 6.1 </x>
        <y> 0.6 </y>
        <z> -3.0 </z>
     </translation> 
     <... moreattrs ... > 
         ... 
     </... moreattrs ...>
         ... ChildNodes ...
  </Transform> 

Variable Types:

 
   VRML97              X3D                              Value
   SF/MF         BaseField/BaseFieldArray
  SF/MFBool         Boolean/Booleans                true|false
  SF/MFColor        Color/Colors                    r g b 0,1
  none              Double/Doubles                  double int
  SF/MFFloat        Float/Floats                    floating point
  SF/MFImage        Image/Images                    
  SF/MFInt32        Integer/Integers          single int | group of ints
  SF/MFNode         BaseNode/BaseNodeArray          Node|Nodes
  SF/MFRotation     Rotation/Rotations              x y z angle
  SF/MFString       String/Strings,              "quoted string"
                    StringsUrl                       "urn"
  SF/MFTime         Time/Times                      
  SF/MFVec2f        Vector2Float/Vector2FloatArray  x y | s t
  SF/MFVec3f        Vector3Float/Vector3FloatArray  
                    BoundingBoxSize        -1 = default | x y z box size
  none              none/Vector3DoubleArray         double fp


Selected XML encoding uses max XML Schema Capabilities.
And extends the box then asks for more..
A Main Contribution:
Enabling Schema Validation of VRML variable types.

The translation, rotation, scale, scaleOrientation and center fields define a geometric 3D transformation consisting of (in order):

  • a (possibly) non-uniform scale about an arbitrary point
  • a rotation about an arbitrary point and axis
  • a translation
The center field specifies a translation offset from the origin of the local coordinate system (0,0,0).

The Diagram(s)

 Object
   |
   +---- Abstract Interfaces ------ Instantiable Nodes
                                     FieldNames
                                     NodeNames

 Base 
  | 
BaseNode 
  | 
  +- AppNode --------------------- Appearance 
  |                                 AppChildNode 
  | 
  | 
  +- AppChildNode -+- MatlNode --- Material 
                   |                ambientIntensity='Float'
                   |                diffuseColor='Color'
                   |                emissiveColor='Color'
                   |                shininess='Float'
                   |                specularColor='Color'
                   |                transparency='Float'
                   |
                   |   
                   +- TxtrNode -+- ImageTexture 
                   |            |   url="urlStrings" 
                   |            +- MovieTexture 
                   |            +- PixelTexture 
                   | 
              +- TextureTranNode - TextureTransform 
                                    center="Vector2Float" 
                                    rotation="Float" 
                                    scale="Vector2Float" 
                                    translation="Vector2Float" 

The diagram shows the language structure and content of nodes and fields.

1. abstract nodes are never instantiated.
2. empty abstract nodes may indicate weakness of the hierarchy.
3. no abstract nodes may indicate weakness and lack of intended extensibility in the hierarchy.
4. you wish to identify unique attributes and methods in the concrete node.
5. you wish to identify common and inherited attributes and methods as close to the hierarchy root as practical.
6. abstract nodes can produce concrete or abstract nodes.
7. concrete nodes never derive from concrete nodes.
8. identify opportunities for multiple inheritance as close to the hierarchy root as possible.

       <Appearance> 
          <ImageTexture url="someStringsUrl" />
          <TextureTransform 
             center="0 0" 
             rotation="0" 
             scale="1 1" 
             translation="0 0" />
       </Appearance> 

The diagram is a way to show unique attributes and methods of a concrete node as well as how it inherits common attributes and methods from abstract nodes that construct the path from the root to the concrete.
My basepage for Diagrams

Example Viewpoint

Viewpoint : X3DBindableNode  { 
  event [in]      SFBool     set_bind     True if first Viewpoint 
  field [in, out] SFFloat    fieldOfView  0.785398 [0,∞)
  field [in, out] SFBool     jump         TRUE
  field [in, out] SFRotation orientation  0 0 1 0  x,y,z [-1,1] angle (-∞,∞)
  field [in, out] SFVec3f    position     0 0 10   (-∞,∞)
  field []        SFString   description  NULL ["string"]
  event [out]     SFTime     bindTime 
  event [out]     SFBool     isBound 
}

   <Viewpoint
      description='"String"'
      examine='Vector3Float'
      fieldOfView='Float'
      jump='Boolean'
      orientation='Rotation'
      position='Vector3Float' />

   <NavigationInfo type='"EXAMINE" "WALK" "FLY" "ANY"'/> 

   <Viewpoint description='"Left View"'
              orientation='0 1 0 -1.57' position='-15 0 0' />

      Viewpoint set_bind = True if first Viewpoint, else False 



TimeSensor : X3DTimeDependentNode, X3DSensorNode { 
  field [in, out] SFTime  cycleInterval    1      [0,1]
  field [in, out] SFBool  enabled          TRUE   [True|False]
  field [in, out] SFBool  loop             FALSE  [True|False]
  field [in, out] SFTime  startTime        0      [0,∞)
  field [in, out] SFTime  stopTime         0      (-∞,∞)
  event [out]     SFTime  cycleTime   
  event [out]     SFFloat fraction_changed  
  event [out]     SFBool  isActive  
  event [out]     SFTime  time   
}

      <TimeSensor DEF='Timer01' 
           cycleInterval='5' enabled='True' loop='True' 
           startTime='0' stopTime='0' />          


From that you can write the XML coding for Viewpoint and TimeSensor.

The "cycle" of a TimeSensor node lasts for cycleInterval seconds. The value of cycleInterval shall be greater than zero. A TimeSensor node can be set up to be active at read time by specifying loop TRUE (not the default) and stopTime less than or equal to startTime (satisfied by the default values).

Lighting Characteristics:

Some Properties:

    location='Vector3Float'

Where the light is located, x,y,z.

      ambientIntensity='Float' 

Ambient illumination results from the scattering and reflection of light originally emitted directly by light sources.

      color='Color' 

What colour is the light? RGB 0 to 1

      intensity='Float'

How bright is it? 0 to 1

      direction='Vector3Float'

Where is it aimed? The direction vector of the illumination emanating from the light source in the local coordinate system.

       attenuation='Vector3Float'

PointLight illumination falls off with distance as specified by three attenuation coefficients.

      radius'Float'
      beamWidth='Float'
      cutOffAngle='Float'

Poinlight, Spotlight: Specifies the radial extent of the solid angle and the maximum distance from location that may be illuminated by the light source.

spotlight pattern

Examples:

   <PointLight DEF='the-light' 
      intensity='0.6' location='0 0 10' radius='50'/> 

   <DirectionalLight DEF='Sun1' on='true'/> 

   <SpotLight beamWidth='1.57' 
       cutOffAngle='0.785' 
       on='false'/> 

PointLight and SpotLight illuminate all objects in the world that fall within their volume of lighting influence regardless of location within the transformation hierarchy. PointLight defines this volume of influence as a sphere centred at the light (defined by a radius) and attenuation with distance. SpotLight defines the volume of influence as a solid angle defined by a radius and a cutoff angle.
DirectionalLight nodes illuminate only the objects descended from the light's parent grouping node, including any descendent children of the parent grouping nodes.

Some Others

  <Transform translation='6.1 0.6 -3.0'> 
     <Shape> 
       <Appearance> 
        <Material/> 
          <ImageTexture url='vts.jpg' /> 
       </Appearance> 
       <Box/> 
     </Shape> 
  </Transform> 

  <TouchSensor DEF='the-touch' /> 

  <Background DEF='grays' 
      groundColor='0 0 0' 
      skyColor='0.41176 0.41176 0.41176 1 1 1' /> 

  <Shape> 
    <Appearance> 
      <Material/> 
    </Appearance> 
    <Text string='"The X3DVRML Test Suite"'/> 
  </Shape> 


     <IndexedFaceSet coordIndex=' 0 4 3 -1  <!-- face A, right 
                                  1 4 0 -1  <!-- face B, back
                                  2 4 1 -1  <!-- face C, left
                                  3 4 2 -1  <!-- face D, front
                                  0 3 2 1'  <!-- face E, bottom 
         <Coordinate point=' 1 0 -1, -1 0 -1, -1 0 1, 1 0 1, 0 2 0' />
     </IndexedFaceSet>

DEF-USE in X3D:

             X3DVRML                              X3DXML

     DEF UserName NodeName {               <NodeName DEF='ID' ...>
         ...                                     ...
     }                                     </NodeName>

        ...                                      ...

     NodeName USE UserName                  <NodeName USE='IDREF' />
                   <IndexFaceSet DEF='MyIFS' ... >
                     ...
                   </IndexedFaceSet>

                     ... 

                   <IndexedFaceSet USE='MyIFS' />

Example Transform, TouchSensor, Background, Indexed Face Set.
Luckily, the VRML97 crew left us the DEF, so we use that for the XML ID and IDREF is X3DXML DEF and USE.

Example Animation

  <Transform . . . > 
    <Shape> 
       <IndexedFaceSet coordIndex='... -1 ... >
           <Coordinate DEF='Moved' point=' x y z, ... />   t0Geometry
       </IndexedFaceSet>                  
    </Shape> 
  </Transform> 

  <CoordinateInterpolator DEF='Mover' 
      key 't0 t1 t2 '                  list time interval keys, 0 to 1
      keyValue ' x y z, ... ' />       one geometry for each key time 

  <TimeSensor DEF='Timer' cycleInterval='5' loop='true' />

  <ROUTE Timer TO Mover.key /> 
  <ROUTE Mover.keyValue TO Moved.point />


  <IndexedFaceSet coordIndex='0 1 3 2 -1 4 5 7 6 -1 6 7 1 0 -1 
                               2 3 5 4 -1 6 0 2 4 -1 1 7 5 3 -1'> 
     <Coordinate DEF='Moved' point='-2 1 1 -2 -1 1 2 1 1 2 -1 1 
                                      2 1 -1 2 -1 -1 -2 1 -1 
                                     -2 -1 -1'/> 
  </IndexedFaceSet> 

  <CoordinateInterpolator DEF='Mover' 
     key='0 0.17 0.34 0.51 0.68 0.86 1' 
     keyValue='-1 1 1 -1 -1 1 1 1 1 1 -1 1 1 1 1 1 -1 -1 -1 1 -1 
             -1 -1 -1 -2 1 1 -2 -1 1 2 1 1 2 -1 1 2 1 -1 2 -1 
             -1 -2 1 -1 -2 -1 -1  1 1 1 -1 -1 1 1 1 1 1 -1 1 1
              1 -1 1 -1 -1 1 1 -1 -1 -1 -1  -1 1 2 -1 -1 2 1 1 
              2 1 -1 2 1 1 2 1 -1 -2 -1 1 -2 -1 -1 -2 -1 1 1 1 
             -1 1 1 1 1 1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 
             -1 2 1 -1 2 1 1 2 1 1 -2 1 1 2 -1 1 -2 -1 1 2 -1 
             -1 -2 -1 -1 1 1 -1 1 1 1 1 1 1 -1 1 1 1 -1 1 1 -1 
             -1 1 -1 -1 -1 -1' /> 

  <TimeSensor DEF='Timer' cycleInterval='5' loop='true'/> 

  <ROUTE fromNode='Timer' fromField='fraction_changed' 
          toNode='Mover'   toField='set_fraction'/> 
  <ROUTE fromNode='Mover' fromField='value_changed' 
          toNode='Moved'   toField='point'/> 

This shows a simple animation using Timer and CoordinateInterpolator.
Nodes contain fields and events.
Messages may be sent between nodes along routes.

X3D XML Simple File

X3DXML: 

   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE X3D PUBLIC 
     "http://www.web3D.org/2002/X3DSchema-instance.xsd">

   <X3D version="3.0" profile="VRML97">
      <head>
         <component name="KeySensor" />
         <component name="GeoVRML" />
         <component name="Nurbs" level="Trimmed" />
         <meta name="description" content="My X3D Example" />
      </head>
      <Scene>

         <!-- Scene graph nodes here -->

      </Scene>
   </X3D>

X3DVRML:

   #X3D V1.0 utf8
   PROFILE Interactive
   COMPONENT GeoVRML
   COMPONENT HumaniodAnimation:2

For a standalone file that is read by an X3D Browser, we think the typical file can look like this.

This alos sohows the X3DVRML encoding for the Profile and Component statements.

web3d x3d syntax

Welcome to a discussion of the XMLization and DOMification of VRML.

Back | Home

Some small steps toward WWWWorld Wide WebHyperMultiMedia

©2002 Williams Publications/hypermultimedia.com

rights reserved - 02/18/02 03/11 03/21 03/22 03/23 03/24.1 03/25 03/27 04/04